package com.hu.zhcc.shiro.service.HealthIntervention;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.shiro.dao.TemplateManagementMapper;
import com.hu.zhcc.shiro.entity.bo.HealthIntervention.TemplateManagement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TemplateManagementServiceImpl implements TemplateManagementService {
    @Autowired
    private TemplateManagementMapper mapper;
    @Override
    public int deleteByPrimaryKey(Integer tempId) {
        return mapper.deleteByPrimaryKey(tempId);
    }

    @Override
    public int insertSelective(TemplateManagement record) {
        return mapper.insertSelective(record);
    }

    @Override
    public TemplateManagement selectByPrimaryKey(Integer tempId) {
        return mapper.selectByPrimaryKey(tempId);
    }

    @Override
    public TemplateManagement findTemplateByCrux(String tempCrux) {
        return mapper.findTemplateByCrux(tempCrux);
    }

    @Override
    public Page<TemplateManagement> selectAllList(Map map, int offset, int limit) {
        PageHelper.startPage(offset,limit);
        List<TemplateManagement> templateManagements = mapper.selectAllList(map);
        PageInfo<TemplateManagement> info = new PageInfo<>(templateManagements);
        return new Page<>(info.getTotal(),templateManagements);
    }

    @Override
    public int updateByPrimaryKeySelective(TemplateManagement record) {
        return mapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByTemplateFalse(Integer tempId) {
        return mapper.updateByTemplateFalse(tempId);
    }

    @Override
    public int updateByTemplateTrue(Integer tempId) {
        return mapper.updateByTemplateTrue(tempId);
    }

    @Override
    public List<TemplateManagement> selectByStart() {
        return mapper.selectByStart();
    }
}
